package discriminant;

/**
 * Created with IntelliJ IDEA.
 * User: admin
 * Date: 16.06.14
 * Time: 19:37
 * To change this template use File | Settings | File Templates.
 */
public class Discriminant {
    private double a;
    private double b;
    private double c;

    public Discriminant(int a, int b, int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public double getA() {
        return this.a;
    }

    public double getB() {
        return this.b;
    }

    public double getC() {
        return this.c;
    }

    public void setA(double value) {
        this.a = value;
    }

    public void setB(double value) {
        this.b = value;
    }

    public void setC(double value) {
        this.c = value;
    }

    public double d() {
        return this.b * this.b - 4 * this.a * this.b;
    }

    public double firstAnswer() {
        if (this.d() > 0) {
            return (-this.b - Math.sqrt(this.d()))/(2 * this.a);
        }
        return -1;
    }

    public double secondAnswer() {
        if (this.d() > 0) {
            return (-this.b + Math.sqrt(this.d()))/(2 * this.a);
        }
        return -1;
    }

    public String toString() {
        return "" + this.a + "*x^2 + " + this.b + "*x + " + this.c + " = 0;\n";
    }
}
